feat(vortex-array): execute primitive interleave arrays - #9291
Conversation
Signed-off-by: Nemo Yu <zyu379@wisc.edu>
Merging this PR will regress 1 benchmark
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Signed-off-by: Nemo Yu <zyu379@wisc.edu>
| let len = validate_selectors(values.len(), |branch| values[branch].len(), branches, rows)?; | ||
| let mut output = BufferMut::with_capacity(len); | ||
| for i in 0..len { | ||
| output.push(values[branches[i].as_()].value(rows[i].as_())); |
There was a problem hiding this comment.
why do you validate once and then used checked accesses?
There was a problem hiding this comment.
You likely want to zip with idx with the output and avoid the bounds check on the output
| if array.value(0).dtype().is_boolean() { | ||
| bool::execute(array, ctx) | ||
| } else if array.value(0).dtype().is_primitive() { | ||
| primitive::execute(array, ctx) | ||
| } else { | ||
| let value_dtype = array.value(0).dtype().clone(); | ||
| vortex_panic!( | ||
| "interleave execution is only implemented for boolean values; value dtype {} is not \ | ||
| yet supported", | ||
| "interleave execution is not implemented for value dtype {}", | ||
| value_dtype |
There was a problem hiding this comment.
I know this is my bad code but the return dtype can we used not the value(0) type
| if array.value(i).as_opt::<Constant>().is_none() { | ||
| array = require_child!(array, array.value(i), i + 2 => Primitive); | ||
| } |
There was a problem hiding this comment.
can use Columnar here
| _ctx: &mut ExecutionCtx, | ||
| ) -> VortexResult<ExecutionResult> { | ||
| let num_values = array.num_values(); | ||
| array = require_child!(array, array.array_indices(), 0 => Primitive); |
There was a problem hiding this comment.
I think this could be bool if thre are two values. I cannot remember if we kept that?
There was a problem hiding this comment.
Technically yes for exactly two values. The current Interleave implementation explicitly rejects Boolean array_indices, including the test from the original encoding PR, so I assumed that restriction was intentional. I’ve left it unchanged, but can add the two-value Boolean special case if that is now desired.
vortex/vortex-array/src/arrays/interleave/mod.rs
Lines 36 to 40 in fb53f39
vortex/vortex-array/src/arrays/interleave/mod.rs
Lines 162 to 179 in fb53f39
There was a problem hiding this comment.
What do you think we should do here
| enum PrimitiveValues<T> { | ||
| Buffer(Buffer<T>), | ||
| Constant { value: T, len: usize }, | ||
| } |
There was a problem hiding this comment.
Don't we have this code everywhere? Also you don't need the len
There was a problem hiding this comment.
Removed the len. Existing types are either type-erased or operation-specific; I think this keeps the hot loop typed and local minimum.
Signed-off-by: Nemo Yu <zyu379@wisc.edu>
Signed-off-by: Nemo Yu <zyu379@wisc.edu>
| let row = (*row).as_(); | ||
| // SAFETY: the caller guarantees that the selected branch and row are in bounds for | ||
| // `values` and the selected physical value buffer. | ||
| slot.write(unsafe { values.get_unchecked(branch).value_unchecked(row) }); |
There was a problem hiding this comment.
Why do you want to do this unchecked vs just using the checked one?
| Self::Buffer(values) => *unsafe { values.get_unchecked(index) }, | ||
| Self::Constant(value) => *value, |
There was a problem hiding this comment.
we could convert this from a branch into a offset load for the constant?
values[index & ty] where ty = usize::MAX if buffer and zero otherwise.
I am not sure what is faster
There was a problem hiding this comment.
This one is actually faster.
Signed-off-by: Nemo Yu <zyu379@wisc.edu>
## Rationale Vortex native geometry arrays should support constructing two-point LineStrings directly from paired Point columns without an Arrow or WKB round trip. ## What changes are included? - Add vortex.st.make_line for paired native Point arrays. - Promote mixed XY, XYZ, XYM, and XYZM inputs, filling absent ordinates with zero. - Propagate CRS metadata, constants, and endpoint nulls. - Build native LineString storage directly and add focused tests and CodSpeed benchmarks. ## Stack #9291 (primitive Interleave execution) has merged into develop, so this PR is now standalone: rebased onto develop, it contains only the spatial function. ST_Length was split into #9290 so each scalar function can also be reviewed independently. Signed-off-by: Nemo Yu <zyu379@wisc.edu>
Summary
Motivation
Interleave previously only had an execution kernel for Boolean values. This adds the corresponding primitive kernel as a general vortex-array capability. Spatial MakeLine uses this support in the separate stacked PR #9201.